﻿using System.Collections.Generic;
using MagicWorld.DDD.Domain.Entity;
using MagicWorld.DDD.Domain.Service.Impl;

namespace MagicWorld.DDD.Domain.Service
{
    /// <summary>
    /// 策略优先级管理
    /// </summary>
    public class EquipmentManager
    {
        private static readonly List<IEquipmentPolicy> POLICIES = new List<IEquipmentPolicy>();

        static EquipmentManager()
        {
            POLICIES.Add(new FighterEquipmentPolicy());
            POLICIES.Add(new MageEquipmentPolicy());
            POLICIES.Add(new DragonKnightEquipmentPolicy());
            POLICIES.Add(new DefaultEquipmentPolicy());
        }

        public bool CanEquip(Player player, Weapon weapon)
        {
            foreach (IEquipmentPolicy policy in POLICIES)
            {
                if (!policy.CanApply(player, weapon))
                {
                    continue;
                }
                return policy.CanEquip(player, weapon);
            }
            return false;
        }
    }
}